import { Schema, Prop } from '@nestjs/mongoose'
import { ApiProperty } from '@nestjs/swagger';
import { Document } from 'mongoose';

export interface IUserProject {
    projectId: string
    identity: string
}

@Schema({ timestamps:true }) // 添加 createdAt 和 updatedAt
export class User extends Document {
    @Prop()
    @ApiProperty({
        description: '用户手机',
        example: '18900000000'
    })
    readonly phone: string

    @Prop()
    @ApiProperty({
        description: '用户密码',
        example: '123456'
    })
    readonly password: string

    @Prop() // 我非常反对这么做，应当使用多对多中间表
    @ApiProperty({
        description: '关联的项目id数组',
    })
    readonly projects: Array<IUserProject>

    @Prop()
    readonly salt?: string
}
